//package org.alvin;
//
//import org.apache.poi.hssf.util.HSSFColor;
//import org.apache.poi.ss.usermodel.*;
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//
//import java.io.IOException;
//import java.io.InputStream;
//import java.nio.file.Files;
//import java.nio.file.Paths;
//
//public class ExcelDemo {
//
//    public static void main(String[] args) throws IOException {
////        try(InputStream is = Files.newInputStream(Paths.get("D:","test.xlsx"))){
////            XSSFWorkbook workbook = new XSSFWorkbook(is);
////            Sheet sheet = workbook.getSheetAt(0);
////
////            CellStyle style = workbook.createCellStyle();
////            style.setFillBackgroundColor(HSSFColor.YELLOW.index);
////            style.setFillForegroundColor(HSSFColor.YELLOW.index);
////            style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
////            style.setWrapText(true);
////            //内容颜色提醒
//////            CellStyle contentErrorStyle = workbook.createCellStyle();
//////            contentErrorStyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
//////            contentErrorStyle.setFillForegroundColor(HSSFColor.YELLOW.index);
//////            contentErrorStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
////            //
////            CellStyle defaultStyle = workbook.createCellStyle();
////            defaultStyle.setFillBackgroundColor(HSSFColor.WHITE.index);
////            defaultStyle.setFillForegroundColor(HSSFColor.WHITE.index);
////            defaultStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
////            for(int r = 0 ; r < sheet.getPhysicalNumberOfRows();r++){
////                Row row = sheet.getRow(r);
////                if(row == null){
////                    continue;
////                }
////
////               for(int c =0;c < row.getPhysicalNumberOfCells();c++){
////                   if(  c ==1){
////                       System.out.println("固定位置设置错误内容---");
//////                       row.getCell(c).setCellStyle(contentErrorStyle);
////                       CellStyle contentErrorStyle = row.getCell(c).getCellStyle();
////                       contentErrorStyle.setFillBackgroundColor(HSSFColor.YELLOW.index);
////                       contentErrorStyle.setFillForegroundColor(HSSFColor.YELLOW.index);
////                       contentErrorStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
////                       row.getCell(c).setCellStyle(style);
////                   }else{
////                       if(row.getCell(c)== null){
////                           continue;
////                       }
////                       System.out.println("设计默认值---");
////                       resetCellStyle(row.getCell(c));
//////                       row.getCell(c).setCellStyle(defaultStyle);
////                   }
////               }
////                Cell cell = row.createCell(8);
////                cell.setCellStyle(style);
////                cell.setCellValue("this is a test");
////            }
////            sheet.autoSizeColumn(8);
////            workbook.write(Files.newOutputStream(Paths.get("D:","test1.xlsx")));
////        }
//
//    }
//
//    private static void resetCellStyle(Cell cell){
//        CellStyle style = cell.getCellStyle();
//        style.setFillBackgroundColor(HSSFColor.WHITE.index);
//        style.setFillForegroundColor(HSSFColor.WHITE.index);
//        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
//        cell.setCellStyle(style);
//    }
//}
